#!/usr/bin/python
# -*- encoding: utf-8 -*-
'''
@File    :   1.py
@Time    :   2020/05/29 20:48:38
@Author  :   Malygos_l 
@Version :   1.0
@Contact :   751756061@qq.com
@WebSite :   www.gitee.com/malygos_l
'''
# Start typing your code from here
'''
给定一个文件，请用正则表达式，逐行匹配提取其中的URL链接信息，并保存到另外一个文件中；
提示，文件有10000行，注意控制每次读取的行数；
'''


import re


url = "http://.+"
with open("homework7/webspiderUrl.txt","r",encoding="UTF-8") as f:
    with open("homework7/URL_info.txt","w",encoding="UTF-8") as f_info:
        # flag = 1
        for line in f.readlines():
            if line != '':
                ret = re.search(url,line)
                if ret != None:
                    f_info.write(ret.group(0)+'\n')
            else:
                break